<template>
<div>
    <div class="edit_prps">
        <a-row>
            <xzqh_s :vertical="vertical" :needyear="needyear"></xzqh_s>
        </a-row>
        <a-divider></a-divider>
        <a-row>
        </a-row>
        <a-form :form="form" :label-col="{ span: 3 }" :wrapper-col="{ span: 12 }" >
            <a-form-item label="名称" >
                <a-input v-model="properties_clone.standard_name" />
            </a-form-item>
             <a-form-item label="全程" >
                <a-input v-model="properties_clone.allname" />
            </a-form-item>
             <a-form-item label="行政区划代码">
                <a-input v-model="properties_clone.code" />
            </a-form-item>
            <a-form-item label="上一级代码">
                <a-input v-model="properties_clone.precode" />
            </a-form-item>
            <a-form-item label="级别">
                <a-input v-model="properties_clone.level"   />
            </a-form-item>
            <a-form-item label="驻地名称" >
                <a-input v-model="properties_clone.station"   />
            </a-form-item>
            <a-form-item label="驻地经度" >
                <a-input-search v-model="properties_clone.stationx"  enter-button @search="onClick_xy" />
            </a-form-item>
            <a-form-item label="驻地纬度" >
                <a-input v-model="properties_clone.stationy"  disabled="true" />
            </a-form-item>
            <a-form-item label="人口数量" v-show="level <=4">
                <a-input-search v-model="properties_clone.persons"   />
            </a-form-item>
             <a-form-item label="行政区域面积" v-show="level <=4">
                <a-input v-model="properties_clone.area"/>
            </a-form-item>
            <a-form-item label="电话区号">
                <a-input v-model="properties_clone.phonecode"/>
            </a-form-item>
            <a-form-item label="邮编编码">
                <a-input v-model="properties_clone.postalcode"   />
            </a-form-item>
             <a-form-item label="设立年份">
                <a-input v-model="properties_clone.setyear" />
            </a-form-item>
             <a-form-item label="辖地级政区" v-show="properties_clone.level<=1">
                <a-input v-model="properties_clone.prop1" />
             </a-form-item>
            <a-form-item label="辖县级政区" v-show="properties_clone.level<=2">
                <a-input v-model="properties_clone.prop2" />
            </a-form-item>
            <a-form-item label="辖乡级政区" v-show="properties_clone.level<=3">
                <a-input v-model="properties_clone.prop3" />
            </a-form-item>
             <a-form-item label="网站" v-show="properties_clone.level<=4">
                <a-input v-model="properties_clone.website" />
            </a-form-item>
             <a-form-item label="罗马字母拼写" >
                <a-input v-model="properties_clone.roman_alphabet_spelling" style="margin-left: 20px;"/>
            </a-form-item>
             <a-form-item label="少数民族语拼写" >
                <a-input v-model="properties_clone.ethnic_minorities_writing" style="margin-left: 20px;" autosize="{ minRows: 5}"/>
            </a-form-item>
             <a-form-item label="地名来历" >
                <a-textarea  v-model="properties_clone.place_origin" style="margin-left: 20px;" autosize="{ minRows: 5}" />
            </a-form-item>
             <a-form-item label="地名含义" >
                <a-textarea  v-model="properties_clone.place_meaning" style="margin-left: 20px;" autosize="{ minRows: 5}"/>
            </a-form-item>
             <a-form-item label="历史沿革" >
                <a-textarea  v-model="properties_clone.place_history" style="margin-left: 20px;" autosize="{ minRows: 5}" />
            </a-form-item>
        </a-form>
        <a-divider>更新</a-divider>
        <a-row style="position: relative;display: flex;justify-content: center;align-items: center;">
            <a-button type="primary" @click="update_props"> 
                更新属性
            </a-button>
        </a-row>
        <get_xy ></get_xy>
    </div>
</div>

</template>
<script>
import xzqh_s from '@/components/map/xzqh_select.vue';
import get_xy from '@/components/platform/edit/get_xy.vue';
export default {
    data() {
        return {
            vertical:'vertical',
            needyear:true,
            properties_clone:{},
            form:this.$form.createForm(this, { name: 'props' }),
        } 
    },
    components: {
        xzqh_s,
        get_xy, 
    },
    mounted() {
        this.$Bus.$on('regionid_change', (code) => {
            this.properties_clone=JSON.parse(JSON.stringify(this.$store.state.Select_Xzqh_properties));
            console.log(this.properties_clone);
        })
        this.$Bus.$on('set_visible_back', (xy) => {
            if(xy.length==2){
                this.properties_clone.stationx=xy[0]
                this.properties_clone.stationy=xy[1]
            }
        })
    },
    methods:{
        onClick_xy(){
            this.$Bus.$emit('set_visible')
            this.$Bus.$emit("set_xy",this.properties_clone.stationx-0,this.properties_clone.stationy-0)
        },
        update_props(){
            let post_json=JSON.parse(JSON.stringify(this.properties_clone))
            delete post_json.xzqh_type
            delete post_json.xzqh_type_name
            delete post_json.enable_status
            delete post_json.photos
            delete post_json.souad
            delete post_json.photos
            this.axios_post("update_props?",{
                code:this.properties_clone.code,
                year:this.$store.state.Select_Year,
                prop:post_json
            }).then((_result)=>{
                if(_result){
                    this.$message.success("更新成功")
                }
                else{
                    this.$message.error("更新成功")
                }
            })
        },
    }
  }
</script>
<style>
.custom input{
    width: 70%;
}
.custom button{
    margin-left: 10px;
}
</style>